<%--
    Document   : index
    Created on : 12-abr-2011, 13:13:22
    Author     : Sergio
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Carrito - appBuy</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="css/style.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="css/coin-slider.css" />
        <script type="text/javascript" src="js/cufon-yui.js"></script>
        <script type="text/javascript" src="js/droid_sans_400-droid_sans_700.font.js"></script>
        <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="js/script.js"></script>
        <script type="text/javascript" src="js/coin-slider.min.js"></script>
    </head>
    <%@ include file="userBar.jsp" %>
    <%@ include file="topBar.jsp" %>
    <%@ include file="sideBar.jsp" %>
    <%@page import="java.io.File"%>
    <%@page import="model.Product"%>
    <%@page import="java.text.NumberFormat"%>

  <div class="content">
    <div class="content_resize">
      <div class="mainbar">
        <%if(carrito.size() == 0){%>
        <h1><br>Carrito vacio:</h1>
        <h2 align="center">Incluya productos pulsando en "AL CARRITO" sobre el producto deseado</h2>
        <%}else{
            float precio = 0;
            for(Product p1: carrito.values()){
                precio = precio + p1.getPrecio();
            }
            NumberFormat nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(2);
            String st=nf.format(precio);
        %>
        <p class="spec"><a href="/Appbuy/FrontController?form=confirmCarritoServlet" class="rm">COMPRAR CARRITO</a></p>
        <h2>&nbsp;Carrito: <%=st%> euros</h2>
        
        <%for(Product p: carrito.values()){
            request.setAttribute("product", p);
        %>
          <jsp:useBean id="product" scope="request" class="model.Product" />
          <div class="article">
           <h2><span><jsp:getProperty name="product" property="nombre" /></span></h2>
          <p class="infopost">Añadida <span class="date">el <jsp:getProperty name="product" property="fecha" /></span> por <a href="/Appbuy/FrontController?form=readUserServlet&userName=<jsp:getProperty name="product" property="usuario" />"><jsp:getProperty name="product" property="usuario" /></a><a href="#" class="com"><b>Precio: <span><jsp:getProperty name="product" property="precio" /> €</span></b></a></p>
          <div class="clr"></div>
          <div class="post_content"><br>
              <b>· Sistema Operativo:</b> <jsp:getProperty name="product" property="so" /><br><br>
              <b>· Ventas:</b> <jsp:getProperty name="product" property="ventas" /><br><br>
              <b>· Breve descripcion:</b> <jsp:getProperty name="product" property="descripcionc" /><br><br>
              <b> · Descripcion:</b> <jsp:getProperty name="product" property="descripcionl" /><br><br>
          </div>
          <%
          String path= request.getServletContext().getRealPath("../../web") + "/images\\APP_" + product.getNombre()+'_'+product.getSo()+".jpg";
          File f = new File(path);
          if (f.exists()){
          %>
          <div class="img"><img src="images/APP_<jsp:getProperty name="product" property="nombre" />_<jsp:getProperty name="product" property="so" />.jpg" width="150" height="150" alt="" class="fl" /></div>
          <%}else{%>
          <div class="img"><img src="images/OS_<jsp:getProperty name="product" property="so" />.png" width="150" height="150" alt="" class="fl" /></div>
          <%}%>
          <div class="clr"></div>
        </div>
        <%}%>
        <p class="spec"><a href="/Appbuy/FrontController?form=deleteCarritoServlet" class="rm">VACIAR CARRITO</a></p>
        <%}%>
      </div>
      <div class="clr"></div>
    </div>
  </div>
    <%@ include file="bottomBar.jsp" %>
</html>